<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <!-- 
        VUE  dom更新是异步的

        vm.$nextTick(() => {})

        Vue.nextTick()

     -->
</head>
<body>
    <div id="app">
        <div ref="box">{{msg}}</div>
        <div v-if="msg1">{{msg1}}</div>
        <div v-if="msg2">{{msg2}}</div>
        <div v-if="msg3">{{msg3}}</div>
        <button @click="change">change</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                msg:'hello',
                msg1:'',
                msg2:'',
                msg3:''
            },
            methods: {
                change(){
                    this.msg = "你好";
                    this.msg1 = this.$refs.box.innerHTML;
                    // this.$nextTick(() => {  //dom已经更新完成
                    //     this.msg2 = this.$refs.box.innerHTML;
                    // })
                    this.$nextTick().then(() => {
                        this.msg2 = this.$refs.box.innerHTML;
                    })
                }
            },
        })
    </script>
</body>
</html>